!function ($) {
  "use strict";
  var SweetAlert = function () { };

  SweetAlert.prototype.init = function () {
    $('#resetPWD').click(function () {
      var iddd = $('#iddddd').val();
      swal({
        title: "重置密码操作",
        text: "尊敬的账户管理员：" + "您正在进行重置用户ID为" + iddd + "密码的操作！" + "\n请确认请求人是否为账户所有者，随后进行下一步操作！",
        type: "warning",
        showCancelButton: true,
        confirmButtonColor: "#DD6B55",
        confirmButtonText: "下一步",
        cancelButtonText: "取消",
        closeOnConfirm: false,
        closeOnCancel: false
      }, function (isConfirm) {
        if (isConfirm) {
          swal({
            title: "请稍等",
            text: "正在与服务器进行传输，为您重置您的新密码！",
            showConfirmButton: false,
            imageUrl: "/static/img/201988888888.gif",
          });
          $.get("/GZGL/AdminSalarySysMenu/RestPWDATUO/", { 'idddddd': iddd }, function (ret) {

            if (ret == "SuccessSend") {
              swal({
                title: "重置成功！",
                text: "您的密码已经发送至您的密保邮箱，请登录查看，并尽快前往修改您的新密码！",
                showConfirmButton: true,
                type: "success",
              });

            }
            if (ret != "SuccessSend") {
              swal("重置失败！", "您的重置密码操作" + "\n出现了" + "未知的错误，请重新提交！", "error");
            }
          })
        }
        else {
          swal("已取消！", "您的密码重置申请已被阻止！", "error");
        }
      });
    });

    //审批操作时产生的sweetalert
    $('#sa-submittt').click(function () {
      var iddd = $('#idddddd').val();
      var type = $('#adminback').val();
      var backup = $('#adminbackup').val();

      if (backup.replace(/(^\s*)|(\s*$)/g, '') == null || backup.replace(/(^\s*)|(\s*$)/g, '') == "") {
        swal("格式错误！", "我们很抱歉的告知您\n\n您在Admin批阅文本框内并没有填入有效的文本批阅格式\n\n它可能只包含了空格或并未输入有效字符，请重新输入", "error");
      }
      else {
        if (type == 0) { var words = "确认"; } else { words = "驳回"; }
        swal({
          title: words + "？",
          text: "正在进行" + words + "申报码为：" + iddd + "的审批！\n\n" + "请注意，您的批复是：" + backup + "\n\n确认吗？",
          type: "warning",
          showCancelButton: true,
          confirmButtonColor: "#DD6B55",
          confirmButtonText: "确认",
          cancelButtonText: "取消",
          closeOnConfirm: false,
          closeOnCancel: false
        }, function (isConfirm) {
          if (isConfirm) {
            swal({
              title: "请稍等",
              text: "正在与服务器进行传输！",
              showConfirmButton: false,
              imageUrl: "/static/img/201904158888.gif",

            });
            $.get("/GZGL/AdminSalarySysMenu/Judge/CheckedToSend/", { 'idddddd': iddd, 'typetype': type, 'adminminbackup': backup }, function (ret) {
              if (ret == "SuccessSaved") {
                swal({
                  title: "保存成功！",
                  text: "您的" + words + "审批\n" + iddd + "\n已保存成功!\n" + "该对话框将在3秒后自动跳转",
                  showConfirmButton: false,
                  type: "success",

                });
                if (iddd.substring(0, 2) == "RW") setTimeout("$(location).attr('href', '/GZGL/AdminSalarySysMenu/AdminShowReportWorking/')", 3000);
                if (iddd.substring(0, 2) == "SI") setTimeout("$(location).attr('href', '/GZGL/AdminSalarySysMenu/AdminShowReportSign/')", 3000);
                if (iddd.substring(0, 2) == "SA") setTimeout("$(location).attr('href', '/GZGL/AdminSalarySysMenu/AdminShowReportSalary/')", 3000);
                if (iddd.substring(0, 2) == "RO") setTimeout("$(location).attr('href', '/GZGL/AdminSalarySysMenu/AdminShowReportOther/')", 3000);

              }
              if (ret != "SuccessSaved") {
                swal("保存失败！", "您的" + words + "审批\n" + iddd + "\n出现了" + ret + "的错误，请重新提交！", "error");
              }
            })
          } else {
            swal("已取消！", "您的提交审批已被阻止！", "error");
          }
        });
      }
    });


  },
    //init
    $.SweetAlert = new SweetAlert, $.SweetAlert.Constructor = SweetAlert
}(window.jQuery),

  //initializing 
  function ($) {
    "use strict";
    $.SweetAlert.init()
  }(window.jQuery);